﻿<Window x:Class="ClimateControl.Client.View.MainView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:ClimateControl.Client.ViewModel"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:p="clr-namespace:ClimateControl.Client.Properties"
        xmlns:c="clr-namespace:ClimateControl.Controls.Converters"
        mc:Ignorable="d"
        Title="Climate Control" Width="240" Height="135" ResizeMode="CanMinimize"
        Icon="/Images/thermometer.ico"
        Topmost="{Binding Source={x:Static p:Settings.Default}, Path=AlwaysOnTop}">

    <Window.Resources>
        <vm:MainViewModelDesign x:Key="MainViewModelDesign"/>
    </Window.Resources>

    <Grid d:DataContext="{Binding Source={StaticResource MainViewModelDesign}}">
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
            <StackPanel VerticalAlignment="Center" Width="100">

                <!-- Air Con indicator -->
                <StackPanel Orientation="Horizontal">
                    <Image Source="{Binding IsAirConOn, Converter={StaticResource BooleanToImageConverter}, ConverterParameter='on.png|off.png'}"
                           Width="16" Height="16"
                           MouseLeftButtonDown="Image_MouseLeftButtonDown"
                           ToolTip="{Binding IsAirConOn,
                                    Converter={StaticResource BooleanToStringConverter},
                                    ConverterParameter='Air conditioning is on. Click for settings.|Air conditioning is off. Click for settings.'}" />
                    <TextBlock Margin="5 0 0 0" Text="{Binding IsAirConOn,
                        Converter={StaticResource BooleanToStringConverter},
                        ConverterParameter='Air Con: On|Air Con: Off'}" />
                </StackPanel>

                    <!-- Fan Lvl indicator-->
                <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="0 5 0 0" Visibility="{Binding IsAirConOn, Converter={StaticResource BooleanToVisibilityConverter}}">                    
                    <Image Source="/Images/bigfanon.png" Height="15" Width="15" />
                    <TextBlock Margin="5 0 0 0" Padding="0 1 0 0" Text="{Binding IsBigFanOn,
                        Converter={StaticResource BooleanToStringConverter},
                        ConverterParameter='Fan Lvl:  High|Fan Lvl:  Low'}" />
                </StackPanel>
                
                <!-- Temp indicator -->
                    <TextBlock Text="{Binding Temperature, StringFormat='{}{0}°C'}"
                               FontSize="16" Margin="0 5 0 0"
                               Visibility="{Binding IsAirConOn, Converter={StaticResource BooleanToVisibilityConverter}}"/>
                
                <!-- Status -->
                <TextBlock Foreground="Gray" Padding="0 5 0 0">
                    <TextBlock.Text>
                        <MultiBinding Converter="{StaticResource StateToStatusConverter}">
                            <Binding Path="State" />
                            <Binding Path="MyLastVote" />
                        </MultiBinding>
                    </TextBlock.Text>
                </TextBlock>

            </StackPanel>
            
            <!-- Progress bar-->
            <ProgressBar
                Foreground="SlateGray" Background="WhiteSmoke"
                x:Name="prog" Orientation="Vertical" HorizontalAlignment="Left" Width="10"
                Margin="0 0 8 0" Height="88" Minimum="0" Maximum="1" Value="{Binding Progress, Mode=OneWay}"
                Visibility="{Binding State, Converter={StaticResource StateToProgressVisibleConverter}}">
                <ProgressBar.ToolTip>
                    <TextBlock Text="{Binding ProgressToolTip}" />
                </ProgressBar.ToolTip>
            </ProgressBar>

            <StackPanel VerticalAlignment="Center" IsEnabled="{Binding State, Converter={StaticResource StateToBooleanConverter}}">

                <!-- Too Hot button -->
                <StackPanel Orientation="Horizontal">
                    <Button Content="Too Hot!" Command="{Binding TooHotCommand}" Width="60" Height="25" />
                    <TextBlock Text="{Binding TooHotVotes.Count}" Width="15" VerticalAlignment="Center" Margin="5 0 0 0"
                               ToolTipService.ShowOnDisabled="True">
                        <TextBlock.ToolTip>
                            <TextBlock Text="{Binding TooHotVotes, Converter={StaticResource VotesToUserList}}"/>
                        </TextBlock.ToolTip>
                    </TextBlock>
                </StackPanel>

                <!-- Perfect button -->
                <StackPanel Orientation="Horizontal" Margin="0 7 0 0" >
                    <Button Content="Perfect." Command="{Binding PerfectCommand}" Width="60" Height="25" />
                    <TextBlock Text="{Binding PerfectVotes.Count}" Width="15" VerticalAlignment="Center" Margin="5 0 0 0"
                               ToolTipService.ShowOnDisabled="True">
                         <TextBlock.ToolTip>
                            <TextBlock Text="{Binding PerfectVotes, Converter={StaticResource VotesToUserList}}"/>
                        </TextBlock.ToolTip>
                    </TextBlock>
                </StackPanel>

                <!-- Too Cold button -->
                <StackPanel Orientation="Horizontal" Margin="0 7 0 0" >
                    <Button Content="Too Cold!" Command="{Binding TooColdCommand}" Width="60" Height="25" />
                    <TextBlock Text="{Binding TooColdVotes.Count}" Width="15" VerticalAlignment="Center" Margin="5 0 0 0" ToolTipService.ShowOnDisabled="True">
                        <TextBlock.ToolTip>
                            <TextBlock Text="{Binding TooColdVotes, Converter={StaticResource VotesToUserList}}"/>
                        </TextBlock.ToolTip>
                    </TextBlock>
                </StackPanel>

            </StackPanel>

            <!-- Vote expiry  -->
            <StackPanel VerticalAlignment="Center">
                <TextBlock FontSize="13" Text="{Binding VoteExpiry, StringFormat='Last {0} minutes'}" Foreground="Gray">
                    <TextBlock.LayoutTransform>
                        <RotateTransform Angle="-90" />
                    </TextBlock.LayoutTransform>
                </TextBlock>
            </StackPanel>

        </StackPanel>
    </Grid>
</Window>
